package cn.changeforyou.web.cloud.auth.controller;

import cn.changeforyou.web.cloud.auth.entity.Menu;
import cn.changeforyou.web.cloud.auth.manager.LoginManager;
import cn.changeforyou.web.cloud.auth.service.SourceInfoService;
import cn.changeforyou.web.cloud.auth.vo.LoginReq;
import cn.changeforyou.web.cloud.auth.vo.LoginVO;
import cn.changeforyou.web.cloud.auth.vo.UserInfoVO;
import cn.changeforyou.web.cloud.webBase.common.model.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("")
public class LoginController {

    @Resource
    private LoginManager loginManager;
    @Resource
    private SourceInfoService  sourceInfoService;

    @PostMapping("simpleLogin")
    public Result<LoginVO> login(@RequestBody @Valid LoginReq req){
        return Result.success(loginManager.login(req));
    }

    @GetMapping("getUserInfo")
    public Result<UserInfoVO> getUserInfo(HttpServletRequest request){
        return Result.success(loginManager.getUserIngoVO());
    }


    @GetMapping("queryUserMenus")
    public Result<List<Menu>> queryUserMenus(HttpServletRequest request){
        return Result.success(loginManager.queryUserMenus());
    }
}
